import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.Window 2.2
import QtQuick.Controls 2.5

Popup {
    id: oksPopup
    dim: true
    width: 800
    height: 600
    padding: 0

    Rectangle {
        id: oksHeader
        anchors.left: parent.left;
        anchors.right: parent.right;
        //anchors.top: parent.top;
        height: 64
        color: "green"
        Text {
            text: qsTr("选择库室")
            font.pixelSize: 24
            anchors.margins: 20
            anchors.left: parent.left
            anchors.verticalCenter: parent.verticalCenter
        }
    }
    BroadcastView {
        id: bcView
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.top: oksHeader.bottom
        anchors.bottom: oksFooter.top
    }
    Rectangle {
        id: oksFooter
        anchors.left: parent.left;
        anchors.right: parent.right;
        anchors.bottom: parent.bottom;

        height: 41

        Button {
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            anchors.margins: 20
            text: qsTr("取消")
            onClicked: {
                oksPopup.close();
            }
        }
        Button {
            anchors.right: parent.right
            anchors.margins: 20
            anchors.bottom: parent.bottom
            text: qsTr("确认")
            onClicked: {
                if(bcView.checkState == Qt.Unchecked) {

                    checkNotify.open()
                }else {
                    authPopup.open();
                }
            }
        }
    }
    NotifyPopup {
        id: checkNotify
        text: qsTr("请选择库室")
    }
    Popup {
        id: authPopup
        width: 600
        height: 250
        dim: true
        padding: 0
        background: Rectangle {

        }
        parent: Overlay.overlay
        anchors.centerIn: parent
        Rectangle {
            id: authHeader
            width: parent.width
            height: 64
            color: "green"
            Text {
                text: qsTr("身份验证")
                font.pixelSize: 24
                anchors.left: parent.left
                anchors.margins: 20
                anchors.verticalCenter: parent.verticalCenter
            }
            Button {
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                anchors.margins: 20
                icon {
                    source: "qrc:/images/close_face.png"
                    color: "white"
                }
                background: Item {

                }
                onClicked: {
                    authPopup.close()
                }

            }
        }
        Text {
            anchors.top: authHeader.bottom
            anchors.left: parent.left
            anchors.margins: 20
            id: title
            text: qsTr("将要进行人脸认证")
        }
        Rectangle {

            width: parent.width
            anchors.top: title.bottom
            anchors.bottom: authBtn.top

            Button {
                id: fingerBtn
                icon {
                     source: "qrc:/images/zhijingmai_2.png"
                }
                background: Item {}
                text: qsTr("指静脉")
                anchors.centerIn: parent
                anchors.horizontalCenterOffset: -100
                display: AbstractButton.TextUnderIcon
                onClicked: {
                    fingerBtn.icon.color = "green"
                    faceBtn.icon.color = "transparent"
                    title.text = qsTr("将要进行指静脉验证")
                    authBtn.text = qsTr("开始验证")
                }
            }
            Button {
                id: faceBtn
                background: Item {}
                icon {
                    source: "qrc:/images/face_2.png"
                    color: "green"
                }
                text: qsTr("人脸识别")
                anchors.centerIn: parent
                anchors.horizontalCenterOffset: 100
                display: AbstractButton.TextUnderIcon
                onClicked: {
                    fingerBtn.icon.color = "transparent"
                    faceBtn.icon.color = "green"
                    title.text = qsTr("将要进行人脸验证")
                    authBtn.text = qsTr("去验证")
                }
            }
        }
        Button {
            id: authBtn
            implicitHeight: 30
            implicitWidth: 80
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 20
            anchors.horizontalCenter: parent.horizontalCenter
            background: Rectangle{
                color: "green"
            }
            text: qsTr("去验证")
            onClicked: {
                authNotify.open()
            }
        }
        NotifyPopup {
            id: authNotify
            width: 180
            text: authBtn.text===qsTr("去验证") ?qsTr("还未录入人脸信息"):
                                               qsTr("还未录入指静脉")

        }

    }
}

